import React from "react";
import { Button, Space } from "antd";
import dictTag from "@/component/Dict-Tag/Dict-Tag";
import { DICT_TYPE } from "@/utils/dict";

/**@description 列表表格字段 */
const getColumns = ({ open = Function, handleDelete = Function, }) => {
    return [
        {
            title: "字典编码",
            key: "id",
            dataIndex: "id",
            width: 80,

        },
        {
            title: "字典标签",
            key: "label",
            dataIndex: "label",
            width: 120,
        },
        {
            title: "字典键值",
            key: "value",
            dataIndex: "value",
            width: 120,
        },
        {
            title: "字典排序",
            key: "sort",
            dataIndex: "sort",
            width: 120,
        },
        {
            title: "状态",
            key: "status",
            dataIndex: "status",
            width: 80,
            render: (value, record) => dictTag({
                type: DICT_TYPE.COMMON_STATUS,
                value: value
            })
        },
        {
            title: "颜色类型",
            key: "colorType",
            dataIndex: "colorType",
            width: 80,
        },
        {
            title: "CSS Class",
            key: "cssClass",
            dataIndex: "cssClass",
            width: 80,
        },
        {
            title: "备注",
            key: "remark",
            dataIndex: "remark",
            width: 100,
        },
        {
            title: "创建时间",
            key: "createDate",
            dataIndex: "createDate",
            width: 150,
            type:"Date"
        },
        {
            title: "操作",
            key: "action",
            dataIndex: "action",
            width: 200,
            render: (text, record) => {
                return (
                    <Space>
                        <Button type="link" onClick={() => open({ actionType: "update", record: { id: record.id } })}>修改</Button>
                        <Button type="link" danger onClick={() => handleDelete(record.id)}>删除</Button>
                    </Space>
                )
            }
        },
    ];
}

export default getColumns;